#include "SOS.h"

volatile TCB* gl_current_task;

extern void task_create(int id, void (*task_fn)(void));


void task0_fn(void)
{
	while(1);
}

void putchar(char c)
{
	while(!TI); // wait for transmitter to be ready
	TI=0; 		// reset transmit flag
	SBUF = c; 	// write character to transmit buffer
} 

char getchar(void)
{ 
	while(!RI); 	// wait for character to be received
	RI =0; 			// reset receive flag
	return SBUF; 	// retrieve character and return
}

/*
 * Contains the main function and other startup code
 */

	


void main(void)
{
	int task_id;
	//Define ar0..7
	_asm
		ar0=0x00
		ar1=0x01
		ar2=0x02
		ar3=0x03
		ar4=0x04
		ar5=0x05
		ar6=0x06
		ar7=0x07
	_endasm;

	for(task_id = 0; task_id <= 4; task_id++)
	{
		task_create(task_id, task0_fn);
	}
	//Enable interrupts
	TMOD = 
	EA = 1;
}

